package com.jdz.service.impl;

import com.google.common.collect.Lists;
import com.jdz.common.ServerResponse;
import com.jdz.dao.ClassNamesMapper;
import com.jdz.dao.ProfessionMapper;
import com.jdz.pojo.ClassNames;
import com.jdz.pojo.Profession;
import com.jdz.service.IClassNamesService;
import com.jdz.vo.ClassNamesVo;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.spi.LocaleServiceProvider;

/**
 * Created by sun
 **/
@Service("IClassNamesService")
public class ClassNamesServiceImpl implements IClassNamesService {
    @Autowired
    ClassNamesMapper classNamesMapper;
    @Autowired
    ProfessionMapper professionMapper;

    private Logger logger = LoggerFactory.getLogger(ClassNamesServiceImpl.class);


//    private ClassNamesVo assembleClassVo(ClassNames classNames){
//        ClassNamesVo classNamesVo = new ClassNamesVo();
//        classNamesVo.setClassname(classNames.getClassname());
//        return classNamesVo;
//    }

    @Override
    public ServerResponse list(String professionName) {

        Profession profession = professionMapper.selectProfessionName(professionName);

        List<ClassNames> classNamesList = classNamesMapper.selectList(profession.getProfessionno());


        if(CollectionUtils.isEmpty(classNamesList)){
            logger.info("未找到班级");
        }


        return ServerResponse.createBySuccess(classNamesList);
    }
}
